<!DOCTYPE html>
<html>

<head>
  <title>web</title>
  <meta charset="UTF-8">
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js"></script>
</head>

<body>
  <div id="send_button">我是按钮</div>
  <script type="text/javascript" charset="UTF-8">
    var socket = io.connect('http://127.0.0.1:5000/echo');
    socket.on('connect', function () {
      console.log('Connected');
    });
    socket.on('message', function (data) {
      console.log(data);
    });
    socket.on('disconnect', function () {
      console.log('Disconnected');
    });
    document.querySelector('#send_button').onclick = function () {
      console.log(111);
      socket.send("发送数据");
    };
  </script>




</body>

</html>